{extend name="public/father" /}


{block name="main"}

<div class="layui-card">
    <div class="layui-card-header">系统日志</div>
    <div class="layui-card-body">

        <div class="layui-btn-container">
            <button type="button" class="layui-btn layui-btn-danger deleteall"><i class="layui-icon layui-icon-delete"></i>清空日志</button>
            <button class="layui-btn layui-btn-primary" onclick="javascript:location.reload();"><i class="layui-icon layui-icon-ok-circle"></i> 刷新页面</button>
        </div>

        <table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>

    </div>
</div>

{/block}


{block name="js"}
<script>
    layui.use(['table'], function(){
        var table = layui.table;

        table.render({
            elem: '#dataTable',
            url: "{:url()}",
            totalRow: true,
            limit: 20,
            cols: [[
                {field: 'username', title: '用户名',	align:'center', width: 120,	totalRowText:'用户名'},
                {field: 'action',   title: '动作/操作',   minWidth: 200, sort: true,	totalRowText:'动作/操作'},
                {field: 'ip',		title: 'IP地址',	width:150,	align:'center',	sort:true,	totalRowText:'IP地址'},
			{field: 'create_time',	title: '时间',	width:180,	align:'center',	totalRowText:'时间'},
            ]],
            page: true
        });

    });

    $('.deleteall').click(function () {
        layer.confirm('真的要清空吗？', {
            // skin: 'layui-layer-lan',
            // closeBtn: 0,
            // anim: 6
        }, function() {
            $.get("{:url('del_all_data')}", {}, function (res) {
                if ( res.code === 1 ){
                    success(res.msg, function () {
                        window.location.reload();
                    });
                } else {
                    error(res.msg);
                }
            }, 'json');
        });

    });

</script>
{/block}